﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace THenu.TinyHourseLib.DesignPattern.Specification_Pattern
{
    /// <summary>
    /// 抽象基类 == 可以附加 规格粒子
    /// </summary>
    public abstract class CompositeSpecification<T> :ISpecification<T>
    {
        /// <summary>
        ///  应当实现自描述
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public abstract bool IsSatisfiedBy(T obj);
         

        public ISpecification<T> And(ISpecification<T> objSpeci)
        {
            return new AndSpecification<T>(this, objSpeci);
        }

        public ISpecification<T> OR(ISpecification<T> objSpeci)
        {
            return new ORSpecification<T>(this, objSpeci);
        }

        public ISpecification<T> NOT(ISpecification<T> objSpeci)
        {
            return new NotSpecification<T>(objSpeci);
        }
    }
}
